﻿using Microsoft.AspNetCore.Mvc;
using MRMDS.Module;
using MRMDS.Module.Response;

namespace Demo.Controllers
{
    [ApiController]
    [Route("Root")]
    public class RootController : ControllerBase
    {
        private readonly GlobalManager global;
        private readonly ILogger<ActorRelateController> _logger;
        public RootController(ILogger<ActorRelateController> logger)
        {
            _logger = logger;
            global = GlobalManager.Instance;
        }

        [Route("Token")]
        [HttpGet]
        public string? RequestToken([FromQuery] string password)
        {
            return Root.GenerateToken(password);
        }

        [Route("Reset")]
        [HttpPost]
        public DefaultResponse Reset([FromQuery] string password)
        {
            if (Root.Reset(password))
            {
                return DefaultResponse.SuccessNullMessage;
            }
            return new DefaultResponse()
            {
                Success = false,
                Message = "Password error."
            };
        }
    }
}